package code.rocky.thread;

public class ThreadTest {

    public static void main(String[] args) {
        System.out.println("in main: "+  Thread.currentThread().getName());
        ThreadTest test = new ThreadTest();
        Thread.currentThread().setName("my-main");
        System.out.println("in main after " + Thread.currentThread().getName());
        test.startThread();
    }

    private void startThread() {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                while (i < 3) {
                    System.out.println("in thread:" + Thread.currentThread().getName());
                    i++;
                }
                i++;
                Thread.currentThread().setName("start-thread");
                System.out.println("in thread after: " + Thread.currentThread().getName());

            }
        });
        t.setName("start-thread-one");
        t.start();
    }
}
